﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Business.Models;
using Business.ProductMannagement;
using Business.ProductMannagement.Dto;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Domain.Repositories;

namespace Business.Controllers
{
    [RemoteService]
    [Area("Business")]
    [Route("api/business/products")]
    public class ProductsController : AbpController
    {
        private readonly IProductsAppService _productAppService;

        public ProductsController(IProductsAppService productAppService)
        {
            _productAppService = productAppService;
        }

        /// <summary>
        /// 创建或更新
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("data-post")]
        public  Task<ProductDto> CreateOrUpdate(CreateOrUpdateProductDto input)
        {
            return _productAppService.CreateOrUpdate(input);
        }
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("product")]
        public  Task<PagedResultDto<ProductDto>> GetAll(GetProductInputDto input)
        {
            return _productAppService.GetAll(input);
        }

        /// <summary>
        /// 获取单个信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("product/{id}")]
        public  Task<ProductDto> Get(Guid id)
        {
            return _productAppService.Get(id);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpDelete]
        [Route("delete")]
        public Task Delete(List<Guid> ids)
        {
            return _productAppService.Delete(ids);

        }
    }
}
